package com.hmall.listener;


import com.hmall.constant.MqConstant;
import com.hmall.service.EsService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ItemListener {
    @Autowired
    private EsService esService;

    /**
     * 监听商品上架
     * @param id
     */
    @RabbitListener(queues = MqConstant.ON_SALE)
    public void listenItemOnSale(String id){
        esService.insertToEsById(Long.valueOf(id));
    }

    /**
     * 监听商品下架
     * @param id
     */
    @RabbitListener(queues = MqConstant.OUT_SALE)
    public void listenHotelDelete(String id){
        esService.deleteEsById(Long.valueOf(id));
    }
}
